package com.toycloud.business.dto.results;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

/**
 * @author hlchan
 * @version 1.0
 * @date 2024/9/5 10:29
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class CommonResult<T> implements Serializable {
    public int total;
    public boolean success;
    public T data;
    public int code;
    public String message;

    public static <T> CommonResult<T> Success(){
        return new CommonResult(0,true, null,0,"");
    }
    public static <T> CommonResult<T> Success(T data){
        return new CommonResult(0,true, data,0,"");
    }
    public static <T> CommonResult<T> Success(int size, T data){
        return new CommonResult(size,true, data,0,"");
    }
    public static <T> CommonResult<T> Fail( ){
        return new CommonResult(0,true, null,1,"");
    }
    public static <T> CommonResult<T> Fail(String msg){
        return new CommonResult(0,true, null,1,msg);
    }
}
